/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package VoiceIdent;

import java.util.List;
import java.util.Vector;

/**
 *
 * @author JArik
 */
public class MfccVector extends Vector<Double>{


    private double distanceToCentroid;
    private Centroid centroid;
    // get Euclidean distance
    public double getDistance(MfccVector vect) throws Exception
    {
        if(vect.size() != this.size()) throw new Exception("Vector size mismatch");
        double dist=0;
        // calc Euclidean distance
        for(int i=0; i<vect.size(); i++)
            //for(int y=0; y<this.size(); y++)
            {
                dist += Math.pow(vect.get(i) - this.get(i),2);
            }
        return Math.pow(dist, 0.5);
    }
    public void attachToCentroid(Centroid center, double distance)
    {
        // remove from previous sector 
        if(centroid != null && !centroid.isParent())
            centroid.getSector().getData().remove(this);
        centroid = center;
        distanceToCentroid = distance;
        
    }
    public Centroid getAttachedCentroid()
    {
        return centroid;
    }
    public double getDistanceToCentroid()
    {
        if(centroid == null || centroid.isParent())
            return Double.MAX_VALUE;
        return distanceToCentroid;
    }
    public void addVoiceFeatures(double [] arr)
    {
        // remove first elemnt, as it represents power
        for(int i=1; i< arr.length; i++)
        {
            this.add(arr[i]);
        }
    }



}
